package com.kws.merchant.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.kws.common.core.domain.R;
import com.kws.merchant.domain.*;
import com.kws.merchant.domain.po.*;
import com.kws.merchant.domain.vo.*;
import com.kws.merchant.service.*;
import com.kws.system.api.domain.PhotovoltaicDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @author : zhangbenting
 * @date : 2024/11/8 15:04
 * @Version: 1.0
 */
@RequestMapping("/userPartner")
@RestController
@Api(value = "用户服务-伙伴", tags = "用户服务-伙伴")
public class UserPartnerController {

    @Autowired
    private UserRemarkService userRemarkService;

    @Autowired
    private UserPartnerService userPartnerService;

    @Autowired
    private OnlineInquiryService onlineInquiryService;

    @Autowired
    private TradePowerStationService tradePowerStationService;

    @Autowired
    private LoanApplicationService loanApplicationService;

    @PostMapping("/getVideoNumber")
    @ApiOperation("获取视频号服务商")
    public R<List<MerchantDetailVo>> getVideoNumber() {
        return R.ok(userPartnerService.getVideoNumber());
    }

    @PostMapping("/getRecommendServe")
    @ApiOperation("获取推荐服务")
    public R<List<UserServeVo>> getRecommendServe() {
        return R.ok(userPartnerService.getRecommendServe());
    }

    @PostMapping("/getPopularServe")
    @ApiOperation("获取热门服务")
    public R<List<UserServeVo>> getPopularServe() {
        return R.ok(userPartnerService.getPopularServe());
    }

    @PostMapping("/getServeList")
    @ApiOperation("获取服务列表")
    @ApiOperationSupport(order = 1, includeParameters = {
            "userServePo.serveName",
            "userServePo.merchantName",
            "userServePo.merchantType",
            "userServePo.type",
            "userServePo.shopsId",
            "userServePo.lngLat",
            "userServePo.pageSize",
            "userServePo.totalPage"
    })
    public R<Page<UserServeVo>> getServeList(@RequestBody UserServePo userServePo) {
        return R.ok(userPartnerService.getServeList(userServePo));
    }

    @PostMapping("/getServeInfo")
    @ApiOperation("获取服务详细信息")
    @ApiOperationSupport(order = 2, includeParameters = {
            "userServePo.serveId",
            "userServePo.lngLat"
    })
    public R<ServeInfoVo> getServeInfo(@RequestBody UserServePo userServePo) {
        return R.ok(userPartnerService.getServeInfo(userServePo));
    }

    @PostMapping("/buyService")
    @ApiOperation("立即购买服务")
    public R<Boolean> buyService(@RequestBody BuyServicePo buyServicePo) {
        return R.ok(userPartnerService.buyService(buyServicePo));
    }

    @PostMapping("/createProgramme")
    @ApiOperation(value = "生成方案")
    public R<ItemUserSchemeEntity> createProgramme(@RequestBody CreateProgrammePo createProgrammePo) {
        return R.ok(userPartnerService.createProgramme(createProgrammePo));
    }

    @PostMapping("/quotationMake")
    @ApiOperation(value = "报价申请")
    @ApiOperationSupport(order = 6, includeParameters = {
            "quotationPo.schemeId",
            "quotationPo.stationId",
            "quotationPo.stationType",
            "quotationPo.reportEndTime",
            "quotationPo.merchantIds"
    })
    public R<Boolean> quotationMake(@RequestBody QuotationPo quotationPo) {
        return R.ok(onlineInquiryService.quotationMake(quotationPo));
    }

    @PostMapping("offerManage")
    @ApiOperation(value = "报价管理")
    @ApiOperationSupport(order = 7, includeParameters = {
            "orderInfoPo.pageSize",
            "orderInfoPo.totalPage"
    })
    public R<Page<QuotationVo>> offerManage(@RequestBody OrderInfoPo orderInfoPo) {
        return R.ok(userPartnerService.offerManage(orderInfoPo));
    }

    @PostMapping("/acceptOffer")
    @ApiOperation(value = "用户接受方案报价")
    @ApiOperationSupport(order = 3, includeParameters = {
            "quotationPo.quotationId"
    })
    public R<Boolean> acceptOffer(@RequestBody QuotationPo quotationPo) {
        return R.ok(onlineInquiryService.acceptOffer(quotationPo.getQuotationId()));
    }

    @GetMapping("/getGoodsRemarkTagCount")
    @ApiOperation(value = "根据商品ID获取商品评价标签数量")
    public R<GoodsRemarkTagVo> getGoodsRemarkTagCount(@RequestParam Long goodsId) {
        return R.ok(userRemarkService.getGoodsRemarkTagCount(goodsId));
    }

    @PostMapping("/getGoodsRemarkList")
    @ApiOperation(value = "获取商品评论列表")
    @ApiOperationSupport(order = 4, includeParameters = {
            "goodsRemarkPo.goodsId",
            "goodsRemarkPo.tag",
            "goodsRemarkPo.remarkType",
            "goodsRemarkPo.pageSize",
            "goodsRemarkPo.totalPage",
    })
    public R<Page<UserRemarkVo>> getGoodsRemarkList(@RequestBody GoodsRemarkPo goodsRemarkPo) {
        return R.ok(userRemarkService.getGoodsRemarkList(goodsRemarkPo));
    }

    @GetMapping("/getShopsScore")
    @ApiOperation(value = "获取店铺评分信息")
    public R<ShopsScoreVo> getShopsScore(@RequestParam Long merchantId) {
        return R.ok(userPartnerService.getShopsScore(merchantId));
    }

//    @PostMapping("/getScheme")
//    @ApiOperation(value = "获取服务方案")
//    public R<SchemeVo> getScheme(@RequestBody OnlineInquiryEntity onlineInquiryEntity) {
//        return R.ok(onlineInquiryService.getScheme(onlineInquiryEntity));
//    }

    @PostMapping("/getServiceProviderList")
    @ApiOperation(value = "获取服务商列表")
    @ApiOperationSupport(order = 5, includeParameters = {
            "serviceProviderPo.merchantType",
            "serviceProviderPo.pageSize",
            "serviceProviderPo.totalPage"
    })
    public R<Page<QuotationVo>> getServiceProviderList(@RequestBody ServiceProviderPo serviceProviderPo) {
        return R.ok(onlineInquiryService.getServiceProviderList(serviceProviderPo));
    }

//    @PostMapping("/getMerchantQuotation")
//    @ApiOperation(value = "获取服务商报价")
//    @ApiOperationSupport(order = 5, includeParameters = {
//            "quotationPo.schemeId"
//    })
//    public R<List<QuotationVo>> getMerchantQuotation(@RequestBody QuotationPo quotationPo) {
//        return R.ok(onlineInquiryService.getMerchantQuotation(quotationPo));
//    }



//    @GetMapping("/getDesignOrConstructionUnitList")
//    @ApiOperation(value = "获取设计或者施工单位列表")
//    public R<List<DesignVo>> getDesignOrConstructionUnitList(@RequestParam String type) {
//        return R.ok(userPartnerService.getDesignOrConstructionUnitList(type));
//    }

    @PostMapping("/tradePowerStation")
    @ApiOperation(value = "买卖电站")
    @ApiOperationSupport(order = 8, includeParameters = {
            "tradePowerStationPo.stationName",
            "tradePowerStationPo.compositeSort",
            "tradePowerStationPo.distanceSort",
            "tradePowerStationPo.stationAddress",
            "tradePowerStationPo.pageSize",
            "tradePowerStationPo.totalPage"
    })
    public R<Page<TradePowerStationEntity>> tradePowerStation(@RequestBody TradePowerStationPo tradePowerStationPo) {
        return R.ok(tradePowerStationService.tradePowerStation(tradePowerStationPo));
    }

    @PostMapping("/loanApplication")
    @ApiOperation(value = "贷款申请")
    @ApiOperationSupport(order = 9, includeParameters = {
            "loanApplicationEntity.serveId",
            "loanApplicationEntity.loanTerm",
            "loanApplicationEntity.loanQuota",
            "loanApplicationEntity.userType",
            "loanApplicationEntity.loanEnterprise",
            "loanApplicationEntity.societyNumber",
            "loanApplicationEntity.applicantName",
            "loanApplicationEntity.applicantPhone",
            "loanApplicationEntity.businessLicense",
            "loanApplicationEntity.certificateNumber",
            "loanApplicationEntity.certificateFront",
            "loanApplicationEntity.certificateBack"
    })
    public R<Boolean> loanApplication(@Valid @RequestBody LoanApplicationEntity loanApplicationEntity) {
        return R.ok(loanApplicationService.loanApplication(loanApplicationEntity));
    }

}
